# Define your item pipelines here
#
# Don't forget to add your pipeline to the ITEM_PIPELINES setting
# See: https://docs.scrapy.org/en/latest/topics/item-pipeline.html


# useful for handling different item types with a single interface
from itemadapter import ItemAdapter


class TianshanPipeline:
    def process_item(self, item, spider):
        print(item['title'])
        print(item["link"])
        print(item["stu"])
        print("-----------------------")
        with open("../files/天善课程信息/课程名称-学习人数-课程连接.txt", "a",encoding='utf-8') as fh: # 这个目录是相对命令行目录，我在命令行执行的
            fh.write(str(item['title'])+"\n"+str(item["link"])+"\n"+str(item["stu"])+"\n"+"-----------------------"+"\n")
        return item
